#!/usr/bin/php
<?php
$ftp_user_name = '';
$ftp_user_pass = '';
$ftp_server = '';

$parameters = $_SERVER['argv'];
array_shift($parameters);
if (! empty($parameters)) {
    if ($parameters[0] == '-d') {
        $result = @unlink("ftp://$ftp_user_name:$ftp_user_pass@$ftp_server/info.php");
        if (! $result) {
            echo "Couldn't delete the file.\n";
            exit(0);
        } else {
            echo "File deleted.\n";
            exit(0);
        }
    }
}

@$file = fopen("ftp://$ftp_user_name:$ftp_user_pass@$ftp_server/info.php", "wb");
if (! $file) {
    echo "Couldn't connect to the server with the given parameters.\n";
    exit(0);
}

$file_contents = <<<EOT
<?php
phpinfo();
EOT;
fwrite($file, $file_contents);
fclose($file);

echo "Done!\n";
exit(0);